import { ApiProperty } from '@nestjs/swagger'
import { Column, Entity } from 'typeorm'

import { CompleteEntity } from '~/common/entity/common.entity'
import { ConfigType } from '~/enums'

@Entity({ name: 'system_config' })
export class ParamConfigEntity extends CompleteEntity {
  @Column({ type: 'varchar', length: 50, comment: '参数分组' })
  @ApiProperty({ description: '参数分组' })
  category: string

  @Column({ type: 'tinyint', comment: '参数类型' })
  @ApiProperty({ description: '参数类型', enum: ConfigType })
  type: ConfigType

  @Column({ type: 'varchar', length: 100, default: '', comment: '参数名称' })
  @ApiProperty({ description: '参数名称' })
  name: string

  @Column({ type: 'varchar', length: 100, unique: true, default: '', comment: '参数键名', name: 'config_key' })
  @ApiProperty({ description: '参数键名' })
  configKey: string

  @Column({ type: 'varchar', length: 500, default: '', comment: '参数键值' })
  @ApiProperty({ description: '参数键值' })
  value: string

  @Column({ type: 'bit', comment: '是否可见' })
  @ApiProperty({ description: '是否可见' })
  visible: boolean

  @Column({ type: 'varchar', length: 500, nullable: true, comment: '备注' })
  @ApiProperty({ description: '备注' })
  remark: string
}
